import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { PetIslandFightResultVo } from "./PetIslandFightResultVo";
import { EntityUtil } from "../../scene/layer/utils/EntityUtil";
import { Language } from "../../../../extend/language/Language";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjCreate } from "../common/ObjCreate";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { PetIslandFightResultItemRenderer } from "./renderer/PetIslandFightResultItemRenderer";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GBitmap } from "../../../../com/mui/controls/GBitmap";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GTileList } from "../../../../com/mui/controls/GTileList";
//class PetIslandFightResultPanel
    
    export  class PetIslandFightResultPanel extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(640, 260);
            titleHeight = 26;
            return;
        }

        /* internal  */setTitlePic(): void
        {
            if (this._isloadCom && this._data) 
            {
                this._titlePic.bitmapData = this._data.fightResult.attackWin ? GlobalClass.getBitmapData(ImagesConst.PetIslandFightWin) : GlobalClass.getBitmapData(ImagesConst.PetIslandFightFail);
            }
            return;
        }

        public set data(arg1: PetIslandFightResultVo)
        {
            this._data = arg1;
            this._attackName.text = arg1.attackName != "" ? "[" + EntityUtil.getProxyName(arg1.attackGuildId) + "]" + arg1.attackName : Language.getString(28225);
            this._defendName.text = arg1.defendName != "" ? "[" + EntityUtil.getProxyName(arg1.defenseGuildId) + "]" + arg1.defendName : Language.getString(28225);
            this._attackNum.htmlText = Language.getStringByParam(28144, arg1.attackPlayers.length);
            this._defendNum.htmlText = Language.getStringByParam(28144, arg1.defendPlayers.length);
            if (arg1.fightResult.attackWin) 
            {
                this._attackReward.htmlText = Language.getStringByParam(28176, arg1.fightResult.grassCount);
                this._defendReward.htmlText = Language.getStringByParam(28177, arg1.fightResult.grassCount);
            }
            else 
            {
                this._attackReward.htmlText = Language.getStringByParam(28181, 0);
                this._defendReward.htmlText = Language.getStringByParam(28182, 0);
            }
            this._attackList.dataProvider = new DataProvider(arg1.attackPlayers);
            this._defendList.dataProvider = new DataProvider(arg1.defendPlayers);
            this._attackList.drawNow();
            this._defendList.drawNow();
            this.setTitlePic();
            return;
        }

        /* internal  */onResCompl(): void
        {
            this._isloadCom = true;
            this.setTitlePic();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=GlobalStyle.setTextFormatLeading(GlobalStyle._textFormat2, 5);
            ObjCreate.createBg(18, 38, 300, 210, this);
            ObjCreate.createBg(322, 38, 300, 210, this);
            ObjCreate.createBg(23, 85, 290, 100, this, ImagesConst.DisabledBg);
            ObjCreate.createBg(327, 85, 290, 100, this, ImagesConst.DisabledBg);
            this._titlePic = ObjCreate.createGBitmap("", 233, -17, this);
            this._attackName = ObjCreate.createGTextField("", 25, 42, 220, 20, this, GlobalStyle._textFormat2);
            this._attackNum = ObjCreate.createGTextField(Language.getStringByParam(28171, 30), 25, 63, 220, 20, this, GlobalStyle._textFormat2);
            ObjCreate.createGTextField(Language.getString(28173), 22, 85, 90, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat2, flash.text.TextFormatAlign.CENTER));
            ObjCreate.createGTextField(Language.getString(28174), 112, 85, 90, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat2, flash.text.TextFormatAlign.CENTER));
            ObjCreate.createGTextField(Language.getString(28175), 202, 85, 105, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat2, flash.text.TextFormatAlign.CENTER));
            this._attackReward = ObjCreate.createGTextField(Language.getStringByParam(28176, 50), 25, 190, 220, 80, this, loc1);
            this._attackReward.wordWrap = true;
            this._attackReward.multiline = true;
            this._attackList = ObjCreate.createTileList(24, 102, 288, 80, this);
            this._attackList.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._attackList.columnWidth = 285;
            this._attackList.rowHeight = 20;
            this._attackList.setStyle("cellRenderer", PetIslandFightResultItemRenderer);
            this._defendName = ObjCreate.createGTextField("", 328, 42, 220, 20, this, GlobalStyle._textFormat2);
            this._defendNum = ObjCreate.createGTextField(Language.getStringByParam(28171, 30), 328, 63, 220, 20, this, GlobalStyle._textFormat2);
            ObjCreate.createGTextField(Language.getString(28173), 313, 85, 90, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat2, flash.text.TextFormatAlign.CENTER));
            ObjCreate.createGTextField(Language.getString(28174), 403, 85, 90, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat2, flash.text.TextFormatAlign.CENTER));
            ObjCreate.createGTextField(Language.getString(28175), 493, 85, 105, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat2, flash.text.TextFormatAlign.CENTER));
            this._defendReward = ObjCreate.createGTextField(Language.getStringByParam(28177, 50), 328, 190, 220, 80, this, loc1);
            this._defendReward.wordWrap = true;
            this._defendReward.multiline = true;
            this._defendList = ObjCreate.createTileList(327, 102, 288, 80, this);
            this._defendList.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._defendList.columnWidth = 285;
            this._defendList.rowHeight = 20;
            this._defendList.setStyle("cellRenderer", PetIslandFightResultItemRenderer);
            LoaderHelp.addResCallBack(ResFileConst.PetIslandFight, this.onResCompl);
            return;
        }

        /* internal */ /* var */_titlePic: GBitmap;

        /* internal */ /* var */_attackName: GTextFiled;

        /* internal */ /* var */_attackNum: GTextFiled;

        /* internal */ /* var */_attackList: GTileList;

        /* internal */ /* var */_attackReward: GTextFiled;

        /* internal */ /* var */_defendName: GTextFiled;

        /* internal */ /* var */_defendNum: GTextFiled;

        /* internal */ /* var */_defendList: GTileList;

        /* internal */ /* var */_defendReward: GTextFiled;

        /* internal */ /* var */_data: PetIslandFightResultVo;

        /* internal */ /* var */_isloadCom: Boolean;
    }
